<template>
  <div>
    <section class="header clearfix">
      <i class="iconfont iconfanhui1" @click="goBack()"></i>
      <span @click="goBack()">{{ $route.query.OName }}/账户流水</span>
    </section>
    <div class="search-box" @keyup.enter="searchFun">
      <i class="iconfont iconsearch1"></i>
      <el-input
        placeholder="输入订单号进行搜索"
        class="search"
        v-model.trim="orderNo"
      ></el-input>
    </div>
    <div class="search-box">
      <section class="option">
        <span>订单类型:</span>
        <el-select
          v-model="orderType"
          @change="searchFun"
          placeholder="请选择"
        >
          <el-option
            v-for="item in orderTypeOptions"
            :key="item.orderTypeId"
            :label="item.orderType"
            :value="item.orderTypeId"
          ></el-option>
        </el-select>
      </section>
      <section class="option">
        <span>时间:</span>
        <el-date-picker
          v-model="time"
          @change="searchFun"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
        >
        </el-date-picker>
      </section>
    </div>
    <div class="table">
      <el-table
        :data="tableData"
        v-loading="loading"
        ref="table"
        tooltip-effect="dark"
        style="width: 100%"
      >
        <el-table-column prop="orderNo" label="订单号" ></el-table-column>
        <el-table-column
          prop="amount"
          label="金额"
          :formatter="moneyFilter"
        ></el-table-column>
        <el-table-column prop="remarks" label="备注"></el-table-column>
        <el-table-column
          prop="operationTime"
          label="操作时间"
        ></el-table-column>
        <el-table-column label="详情">
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="detail(scope.row.accountId, scope.row.detailId)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="current"
        :page-sizes="[6, 12, 24, 36]"
        :page-size="pageSize"
        layout="sizes, prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import base from "@/assets/js/base";
import { requestApiPost } from "../api/api";
import { reqRep } from "../report/reqReport";
import { resRep } from "../report/resReport";
export default {
  name: "balanceList",
  data() {
    return {
      infoDialog: false,
      operateDialog: false,
      time: [],
      orderNo: "",
      checked: true,
      current: 1,
      total: null,
      pageSize: 6,
      isNeed: "1",
      dialogTableVisible: false,
      formLabelWidth: "160px",
      orderType: "0",
      orderTypeOptions: [],
      tableData: [],
      orderItems: [],
      info: {
        type: "1",
        specialType: "",
        id: "",
        head: ""
      },
      billAmount: 0,
      dialogTitle: "",
      gridData: [],
      sendEmail: ""
    };
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    },
    sendFun() {
      this.operateDialog = true;
    },
    //账单详情
    detail(accountId, detailId) {
      this.$router.push({
        path: "/balanceDetail",
        query: { accountId: accountId, detailId: detailId }
      });
    },
    lookBill() {
      this.dialogTableVisible = true;
    },
    searchFun() {
      this.current = 1;
      this.getData();
    },
    handleSizeChange(e) {
      this.pageSize = e;
      this.getData();
    },

    handleCurrentChange(e) {
      this.current = e;
      this.getData();
    },
    //获取订单类型
    getOrderType() {
      var reqData = {
        orderType: "",
        current: 1,
        pageSize: 999
      };
      let reqReport = reqRep({ traCode: "_LIST_ORDER_TYPE", data: reqData });
      requestApiPost(reqReport).then(data => {
        let resReport = resRep(data);
        this.loading = false;
        if (resReport.getReCode() != "0000") {
          this.$message({
            message: resReport.getReMsg(),
            type: "error"
          });
        } else {
          this.orderTypeOptions = resReport.data.records;
          this.orderTypeOptions.unshift({
            orderType: "全部",
            orderTypeId: "0"
          });
          this.getData();
        }
      });
    },
    getData() {
      this.loading = true;
      var reqData = {
        orderType: this.orderType,
        orderNo: this.orderNo,
        startTime: this.time ? this.time[0] : "",
        endTime: this.time ? this.time[1] : "",
        accountId: this.$route.query.accountId,
        current: this.current,
        pageSize: this.pageSize
      };
      let reqReport = reqRep({ traCode: "_LIST_ACC_SEQ", data: reqData });
      requestApiPost(reqReport).then(data => {
        let resReport = resRep(data);
        this.loading = false;
        if (resReport.getReCode() != "0000") {
          this.$message({
            message: resReport.getReMsg(),
            type: "error"
          });
        } else {
          this.tableData = resReport.data.records;
          this.total = resReport.data.total;
        }
      });
    },
    baseFilter(a, b, c) {
      if (c > 0) {
        return c;
      } else {
        return "-";
      }
    },
    dateFilter(a, b, c) {
      if (c) {
        return base.timeSwitch(c);
      }
    },
    moneyFilter(a, b, c) {
      if (c) {
        return c;
      } else {
        return 0;
      }
    }
  },
  filters: {
    dateFilter(c) {
      if (c) {
        return base.timeSwitch(c);
      }
    }
  },
  created() {
    this.getOrderType();
  }
};
</script>
<style scoped>
.header {
  padding: 15px;
  height: 50px;
  box-sizing: border-box;
  font-size: 14px;
  border-bottom: 1px solid #eee;
}
.header i {
  margin-right: 5px;
  cursor: pointer;
}
.header span {
  cursor: pointer;
}
.opt-user {
  padding: 20px 15px;
}
.opt-user > section {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}
.opt-user i {
  font-size: 20px;
  margin-right: 5px;
  vertical-align: middle;
}
.opt-user .iconadd1 {
  color: #13cb6e;
}
.opt-user .iconbiaoge-xiazai {
  color: #33ac37;
}
.add-user:hover {
  color: #13cb6e;
}
.input-user:hover {
  color: #33ac37;
}
.menu-swtich {
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #eee;
}
.menu-swtich li {
  display: inline-block;
  padding: 0 15px;
  cursor: pointer;
}
.active {
  color: #13cb6e;
  border-bottom: 2px solid #13cb6e;
}
.search-box {
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #eee;
}
.search-box i {
  font-size: 18px;
  margin-left: 15px;
  color: #999;
  vertical-align: middle;
}
.search-box .search {
  display: inline-block;
  width: 80%;
}
.search-box .option {
  display: inline-block;
  margin-left: 15px;
}
.search-box .option .el-select {
  width: 150px;
}
.showMoney {
  padding: 15px;
}
.showMoney .sm-h {
  margin-bottom: 20px;
}
.sm-h section {
  display: inline-block;
  margin-right: 20px;
}
.sm-h .month {
  margin-left: 10px;
  color: #999;
}
i {
  color: #999;
  font-size: 16px;
}
.download {
  float: right;
  font-size: 14px;
  margin-right: 0 !important;
  cursor: pointer;
}
.download:hover,
.download:hover i {
  color: #13cb6e !important;
}
.sm-f > ul {
  display: inline-block;
  margin-right: 15px;
  color: #666;
}
.sm-f .value {
  color: #666;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 5px;
}
.sm-f .no {
  opacity: 0;
}
.sm-f .button {
  float: right;
  width: 140px;
  text-align: center;
  height: 50px;
  font-size: 20px;
  line-height: 50px;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  background-color: #13cb6e;
}
.table {
  margin-top: 4px;
}
.table .table-name {
  width: 100%;
  padding: 10px;
  background-color: #eee;
}
.table .table-value {
  width: 100%;
  padding: 10px;
  cursor: pointer;
}
.table .table-value:hover {
  background-color: #eee;
}
.table .table-name li,
.table .table-value li {
  position: relative;
  float: left;
  width: 20%;
  box-sizing: border-box;
}
.table .table-value h6 {
  color: #666;
  font-size: 14px;
}
.table .table-value p {
  color: #999;
  font-size: 12px;
}
.table .table-value .iconfont {
  position: absolute;
  top: 50%;
  right: 20px;
  margin-top: -8px;
  font-size: 16px;
}
.rests {
  float: right;
}
.el-form-item,
h4 {
  width: 390px;
  margin: 0 auto 22px;
}
.tip {
  width: 228px;
  text-align: center;
  background: #ccc;
  padding: 5px 10px;
  margin: 0 auto 22px;
  cursor: pointer;
}
.el-input,
.el-select {
  width: 228px;
}
h4 {
  color: #999;
}
.order-box li {
  text-align: center;
  line-height: 30px;
  cursor: pointer;
  margin-bottom: 2px;
  border-radius: 3px;
  background-color: #eee;
}
.order-box li:hover {
  color: #13cb6e;
}
.message {
  color: #666;
  text-align: center;
}
.file {
  margin-top: 10px;
  color: #999;
  text-align: center;
}
.billAmount-box {
  font-size: 14px;
  color: #999;
}
.billAmount {
  font-weight: 600;
  font-size: 16px;
  color: #333;
}
</style>
